# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
import openpyxl

class ZhilianZhaopingGuiyangRealtyPipeline(object):
    def open_spider(self, spider):
        self.wb = openpyxl.Workbook()
        self.sheet = self.wb.active
        self.sheet.append(["岗位名称", "公司名称",'所在城市', '公司类型', '公司规模','薪水','工作经验要求','学历要求','招聘状态','福利'])

    def process_item(self, item, spider):
        # 获取字典 item 的所有值
        temp = item.values()
        # 将值转换成列表数据
        data = list(temp)
        # 添加到excel 文件
        self.sheet.append(data)

    def close_spider(self, spider):
        self.wb.save("房地产.csv")
